{include file="publics/head"/}


<body class="no-skin">
{include file="publics/header"/}
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    {include file="publics/sidebar"/}
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            {include file="publics/breadcrumbs"/}

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                {include file="publics/set"/}

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal"  id="form" action="{:url('update')}" method="post">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10">
                                    上级菜单 </label>
                                <input name="id" id="id" value="{$wxmenu.menu_id}" type="hidden">
                                <div class="col-sm-9">
                                    <select id="parentid" name="parentid" class="rcol-xs-10 col-sm-5">
                                        <option value="0" {if condition="$wxmenu.parentid eq 0"}selected="selected"{/if}>顶级菜单</option>
                                        {volist name="wxoption" id="v"}
                                            <option value="{$v.menu_id}" {if condition="$wxmenu.parentid eq $v['menu_id']"}selected="selected"{/if}>{$v['name']}</option>
                                        {/volist}

                                    </select>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 菜单名称 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="name" id="name" class="rcol-xs-10 col-sm-5" placeholder="菜单名称"
                                           value="{$wxmenu.name}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 类型 </label>
                                <div class="col-sm-9">
                                    <select id="type" name="type" class="rcol-xs-10 col-sm-5">
                                        <option value="1" {if condition="$wxmenu.type eq 1"}selected="selected"{/if}>触发关键字</option>
                                        <option value="2" {if condition="$wxmenu.type eq 2"}selected="selected"{/if}>链接</option>
                                    </select>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2">
                                    KEY </label>
                                <div class="col-sm-9">
                                    <input type="text" name="key" id="key" placeholder="KEY"
                                           class="col-xs-10 col-sm-5" value="{$wxmenu.key}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2">
                                    URL </label>
                                <div class="col-sm-9">
                                    <input type="text" name="url" id="url" placeholder="URL"
                                           class="col-xs-10 col-sm-5" value="{$wxmenu.url}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 显示状态 </label>
                                <div class="control-label no-padding-left col-sm-1">
                                    <label>
                                        <input name="status" id="status"
                                        {if condition="$wxmenu.status eq 1"}checked="checked"{/if}
                                        value="1" class="ace ace-switch ace-switch-2" type="checkbox" />
                                        <span class="lbl"></span>
                                    </label>
                                </div>
                                <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
										</span>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 排序 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="order" id="order" placeholder="" class="col-xs-10 col-sm-5"
                                           value="{$wxmenu.order}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">越小越靠前</span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    {include file="publics/footer"/}

</div><!-- /.main-container -->

{include file="publics/footerjs"/}
<!-- inline scripts related to this page -->

<script type="text/javascript">
    $(function () {
        $(".btn.btn-info").click(function () {
            var title = $("#title").val();
            if (title == '') {
                bootbox.alert({
                    buttons: {
                        ok: {
                            label: '确定',
                            className: 'btn-myStyle'
                        }
                    },
                    message: '菜单名称不能为空。',
                    title: "友情提示",
                });
                return false;
            }

        })
        
        $(".submit").click(function () {
        	var jsonData = {
                'id' : $("#id").val(),
        		'parentid' : $("select[name='parentid']").val(),
        		'name' : $("#name").val(),
        		'type' : $("#type").val(),
        		'key' : $("#key").val(),
        		'url' : $("#url").val(),
        		'status' : $("input[name='status']:checked").val(),
        		'order' : $("#order").val(),
        	}
        	console.log(jsonData)
        	$.ajax({
    			type: "post",
    			url: "{:url('update')}",
    			dataType: 'JSON',
    			data: jsonData,
    			error: function () {
    				return false;
    			},
    			success: function (data) {
    				bootbox.alert({  
                        buttons: {  
                           ok: {label: '确定',className: 'btn-danger'}  
                        },  
                        message: data.message,
                        callback: function() {  
                          	location.reload(); 
                        },  
                        title: "系统提示",  
                    });
    			}
    		});
        	
        })

    })
</script>

</body>
</html>
